Document the exact predicate of the has_nft function family - #135
Open
MavenRain wants to merge 1 commit into
Open
Document the exact predicate of the has_nft function family#135MavenRain wants to merge 1 commit into
MavenRain wants to merge 1 commit into
Conversation
The doc comments said the functions check that a Value "carries an NFT". What they check is a quantity of exactly 1 within the given Value. That proves nothing about chain-level uniqueness, and a fungible token present with a quantity of 1 also passes. State the predicate in all four doc comments and add an IMPORTANT admonition with the caveat, following the discussion in aiken-lang#121. Also fix the has_nft_strict examples that call the function with value1 / value3 while the example binds value. See aiken-lang#121 Signed-off-by: Onyeka Obi <softwareengineerasaservant@isurvivable.cv>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See #121.
Problem
The doc comments of
has_any_nft,has_any_nft_strict,has_nftandhas_nft_strictsay the functions check that aValue"carries an NFT". As #121 points out, the name and the docs imply a chain-level property the functions cannot observe. The actual predicate is local to the givenValue: a quantity of exactly 1 (and, for the strict variants, no other assets beside Ada). A fungible token present with a quantity of 1 also satisfies it.The rename proposed in #121 is contested (uniqueness is extrinsic under any name), so this PR takes the documentation route instead: keep the names, state the predicate exactly, and warn about the local scope of the check.
Fix
has_any_nft), of a single asset (has_any_nft_strict), or of the given asset (has_nft,has_nft_strict).[!IMPORTANT]admonition (house style, as used elsewhere inassets.ak): the check is local to the givenValue, does not prove chain-level uniqueness, and a fungible token present with a quantity of 1 also passes.has_nft_strictexamples that call the function withvalue1/value3while the example bindsvalue.Docs only; no code change. If a rename is decided in #121 after all, this text carries over to the new names.
Testing
aiken fmt --checkclean;aiken check: 986 passed, 0 failed (969 unit, 17 property).